// import { createStore, Store } from 'vuex';
// import persistedState from 'vuex-persistedstate';
// import SecureLS from 'secure-ls';
// const ls = new SecureLS({ isCompression: false });

// declare module '@vue/runtime-core' {
//   // 声明自己的 store state
//   interface State {
//     count: number;
//   }

//   // 为 `this.$store` 提供类型声明
//   interface ComponentCustomProperties {
//     $store: Store<State>;
//   }
// }
// export default createStore({
//   state: {
//     count: 0,
//     siderBarType: 1,
//     themeType: 'green',
//   },
//   mutations: {
//     setSiderBarType(state: any, payload: any) {
//       state.siderBarType = payload;
//     },
//     setCount(state: any, payload: any) {
//       state.count = payload;
//     },
//   },
//   actions: {},
//   plugins: [
//     persistedState({
//       storage: {
//         getItem: key => ls.get(key),
//         setItem: (key, value) => ls.set(key, value),
//         removeItem: key => ls.remove(key),
//       },
//     }),
//   ],
// });
import { InjectionKey } from 'vue';
import { createStore, useStore as baseUseStore, Store } from 'vuex';

export interface State {
  count: number;
}

export const key: InjectionKey<Store<State>> = Symbol();

export const store = createStore<State>({
  state: {
    count: 0,
  },
  mutations: {
    setSiderBarType(state: any, payload: any) {
      state.siderBarType = payload;
    },
    setCount(state: any, payload: any) {
      console.log(payload, 111);
      state.count = payload;
    },
  },
});

// 定义自己的 `useStore` 组合式函数
export function useStore() {
  return baseUseStore(key);
}
